<?php

/**
 * AbetDepartment form base class.
 *
 * @method AbetDepartment getObject() Returns the current form's model object
 *
 * @package    sfproject
 * @subpackage form
 * @author     Your name here
 */
abstract class BaseAbetDepartmentForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'           => new sfWidgetFormInputHidden(),
      'code'         => new sfWidgetFormInputText(),
      'name'         => new sfWidgetFormInputText(),
      'phone'        => new sfWidgetFormInputText(),
      'college_Code' => new sfWidgetFormPropelChoice(array('model' => 'AbetCollege', 'add_empty' => false, 'key_method' => 'getCode')),
      'Head'         => new sfWidgetFormPropelChoice(array('model' => 'AbetDepartmentHead', 'add_empty' => false, 'key_method' => 'getCode')),
      'created_at'   => new sfWidgetFormDateTime(),
      'updated_at'   => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'           => new sfValidatorChoice(array('choices' => array($this->getObject()->getId()), 'empty_value' => $this->getObject()->getId(), 'required' => false)),
      'code'         => new sfValidatorString(array('max_length' => 10)),
      'name'         => new sfValidatorString(array('max_length' => 50)),
      'phone'        => new sfValidatorString(array('max_length' => 9, 'required' => false)),
      'college_Code' => new sfValidatorPropelChoice(array('model' => 'AbetCollege', 'column' => 'code')),
      'Head'         => new sfValidatorPropelChoice(array('model' => 'AbetDepartmentHead', 'column' => 'code')),
      'created_at'   => new sfValidatorDateTime(array('required' => false)),
      'updated_at'   => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'AbetDepartment', 'column' => array('code'))),
        new sfValidatorPropelUnique(array('model' => 'AbetDepartment', 'column' => array('name'))),
      ))
    );

    $this->widgetSchema->setNameFormat('abet_department[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'AbetDepartment';
  }


}
